package net.siufung.market.base.app.controller.model.appMenu;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.siufung.core.model.AbstractDto;
import net.siufung.market.base.app.mapper.entity.AppMenu;
import org.apache.commons.compress.utils.Lists;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author 陈建峰
 * @date 2023/7/16 6:01 PM
 * @since V1.0.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="AppMenuSaveBatchDto", description="系统应用菜单表创建传参对象")
public class AppMenuSaveBatchDto extends AbstractDto {

    private static final long serialVersionUID = 3768633592710841093L;
    /**
     * 应用id
     */
    @ApiModelProperty(value = "应用id")
    @NotNull(message = "应用id不能为空!")
    private Integer appId;

    /**
     * 菜单id列表
     */
    @ApiModelProperty(value = "菜单id列表")
    @NotEmpty(message = "菜单id列表不能为空!")
    private List<Integer> menuIdList;


    public List<AppMenu> toList(){
        List<AppMenu> appMenuList = Lists.newArrayList();
        AppMenu appMenu;
        for (Integer menuId: menuIdList) {
            appMenu = new AppMenu();
            appMenu.setAppId(appId);
            appMenu.setMenuId(menuId);
            appMenuList.add(appMenu);
        }
        return appMenuList;
    }

}
